// 引入vue
import Vue from 'vue';
// 引入VueRouter
import VueRouter from 'vue-router';
// 引入子组件
import Main from "@/views/Main";
import Home from "@/views/Home";
import User from "@/views/User";
import Mall from "@/views/Mall";
import Login from "@/views/Login";
import PageOne from "@/views/other/pageOne"
import PageTwo from "@/views/other/pageTwo"

// 全局注入VueRouter
Vue.use(VueRouter)

export default new VueRouter({
    mode: 'history',
    // path是位置    commponent是对应的组件名称
    routes: [
        {
            // path:路由组件对应的位置    与router-link对应
            path: '/',
            // name，路由名称   通过name进行页面的跳转
            name: 'main',
            // 对应的组件名称
            component: Main,
            // 子路由
            children: [
                {
                    path: '/home',
                    name: 'home',
                    component: Home
                },
                {
                    path: '/user',
                    name: 'user',
                    component: User
                },
                {
                    path: '/mall',
                    name: 'mall',
                    component: Mall
                },
                {
                    path: '/page1',
                    name: 'page1',
                    component: PageOne
                },
                {
                    path: '/page2',
                    name: 'page2',
                    component: PageTwo
                },
            ]
        },
        {
            path:'/login',
            name:'login',
            component:Login
        }
    ],

})